{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from utils import calculate_mean_accuracy, get_radiuses_for_distance_contour_lines, draw_theoretical_accuracies \n",
    "\n",
    "import numpy as np\n",
    "from scipy.optimize import LinearConstraint, NonlinearConstraint, minimize, minimize_scalar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "np.random.seed(42)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAhoAAAIzCAYAAABGGrDYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nO3dX6hlV50n8N+6TiQN8xAwQyepVLqNhKGlBacfjDoJrTSFf8ZpXxR0YKY7CMGOwhRMP0mg6SYP/TSUgx1DYUwjDAoy0p2WQMiD2Ak9GZyWacWWgRghSVVUoqAjdtB0rXm49ySnbp177vmz915rr/X5wCVVde89d9+qVJ3v+a7fWjvlnAMAYAwHpS8AAGiXoAEAjEbQAABGI2gAAKMRNACA0fyLde/8+m+9dbAtKW/71IeGeihY6bl3/kHpS2jWt186M+jjXXjgyUEfD4b01N/8bpry6931778+2fbPqb+3iFOCxlCEDMYgWMzX+fvvjgiBA3owatAQMBiacFHGW268NHirEXEYOIQNaNskjQYAsFo6aHtccrSg0VOb8fJzlyIi4vrbhn/F1zPtRR8so0DbBg0aLYSLRWiY6nOFk6sJF/1aBI4IoYO+pIPJ5zMnNVhfM9eQsRwO9gkZrVxHKQLGPLzlxv7+3wT2M0ijMceQUcsTey3XUdIiZAgbdZsyZBgSpScpmdFYaw4hY45P4MevuaUlFoGCTZjdgDbsHDRqDxhzDBfrLH8/cw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a+AqjGv/vV/53suTaldG9E3Lv0SxdzzhePfnwmIp5fet8LcW1bsepjzkTEiyd9TUsnANCJo1Bx8YR3rwo8x9d1NvmYq1g6AQAiDtuJs0s/vzUiLu/wMVcRNACAiIhvRMQdKaU3ppReHxEfiYhHj33MoxHxn9Kht0fET3POJy6bRFg6AQAiIuf8SkrpkxHxeBxub/18zvk7KaWPH73/oYh4LA63tj4Th9tb7zntcVPOdWyrAQDaY+kEABiNoAEAjEbQAABGI2gAAKMRNACA0QgaAMBoBA0AYDT/H70EZhhJBcd6AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 720x720 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "rssi_accuracy = 4\n",
    "beacons_location = np.array([[0.5, 0.5], [2.5, 3.5], [1, 1]])\n",
    "# beacons_location = np.array([[0, 0]])\n",
    "beacon_number = beacons_location.shape[0]\n",
    "\n",
    "x_len = 3\n",
    "y_len = 4\n",
    "delta = 0.01\n",
    "radiuses = get_radiuses_for_distance_contour_lines(rssi_accuracy)\n",
    "\n",
    "calculate_mean_accuracy(x_len, y_len, beacons_location, radiuses)\n",
    "\n",
    "draw_accuracies = lambda locations: draw_theoretical_accuracies(x_len, y_len, locations, radiuses)\n",
    "draw_accuracies(beacons_location)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Beacon location optimization"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Our goal is to minimize mean accuracy\n",
    "\n",
    "We have next variables:\n",
    "\n",
    "$n$ - number of beacons  \n",
    "$x_{len}$ - max x coordinate of room  \n",
    "$y_{len}$ - max y coordinate of room\n",
    "\n",
    "$x_i$, $i=\\overline{1,n}$ - x coordinate of nth beacon  \n",
    "$y_i$, $i=\\overline{1,n}$ - y coordinate of nth beacon\n",
    "\n",
    "We have next constraints:\n",
    "\n",
    "$ 0 \\leq x_i \\leq x_{len}$, $i = \\overline{1,n} $  \n",
    "$ 0 \\leq y_i \\leq y_{len}$, $i = \\overline{1,n} $"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def beacon_locations_from_x(x):\n",
    "    x, y = np.split(x, 2)\n",
    "    return  np.vstack([x, y]).T\n",
    "    \n",
    "def obj(x):\n",
    "    return calculate_mean_accuracy(x_len, y_len, beacon_locations_from_x(x), radiuses)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Initial Objective (Accuracy): 0.6699099035424747\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAhoAAAIzCAYAAABGGrDYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nO3dX6hlV50n8N+6TiQN8xAwQyepVLqNhKGlBacfjDoJrTSFf8ZpXxR0YKY7CMGOwhRMP0mg6SYP/TSUgx1DYUwjDAoy0p2WQMiD2Ak9GZyWacWWgRghSVVUoqAjdtB0rXm49ySnbp177vmz915rr/X5wCVVde89d9+qVJ3v+a7fWjvlnAMAYAwHpS8AAGiXoAEAjEbQAABGI2gAAKMRNACA0fyLde/8+m+9dbAtKW/71IeGeihY6bl3/kHpS2jWt186M+jjXXjgyUEfD4b01N/8bpry6931778+2fbPqb+3iFOCxlCEDMYgWMzX+fvvjgiBA3owatAQMBiacFHGW268NHirEXEYOIQNaNskjQYAsFo6aHtccrSg0VOb8fJzlyIi4vrbhn/F1zPtRR8so0DbBg0aLYSLRWiY6nOFk6sJF/1aBI4IoYO+pIPJ5zMnNVhfM9eQsRwO9gkZrVxHKQLGPLzlxv7+3wT2M0ijMceQUcsTey3XUdIiZ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ERFvi4hncs7P5px/GRFfiogPHvuYD0bEF/KhpyPihpTSzesedG2j8dTf/G7a54oBVnrTn5a+AqjGv/vV/53suTaldG9E3Lv0SxdzzhePfnwmIp5fet8LcW1bsepjzkTEiyd9TUsnANCJo1Bx8YR3rwo8x9d1NvmYq1g6AQAiDtuJs0s/vzUiLu/wMVcRNACAiIhvRMQdKaU3ppReHxEfiYhHj33MoxHxn9Kht0fET3POJy6bRFg6AQAiIuf8SkrpkxHxeBxub/18zvk7KaWPH73/oYh4LA63tj4Th9tb7zntcVPOdWyrAQDaY+kEABiNoAEAjEbQAABGI2gAAKMRNACA0QgaAMBoBA0AYDT/H70EZhhJBcd6AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 720x720 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "bnds = [(0, x_len) for i in range(beacon_number)] + [(0, y_len) for i in range(beacon_number)]\n",
    "\n",
    "x0 = np.array([0.5, 2.5, 1, 0.5, 3.5, 1])\n",
    "# x0 = np.array([1.5, 2])\n",
    "# x0 = np.ones(beacon_number*2)\n",
    "\n",
    "# show initial objective\n",
    "print('Initial Objective (Accuracy): ' + str(obj(x0)))\n",
    "draw_accuracies(beacon_locations_from_x(x0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Optimization terminated successfully.    (Exit mode 0)\n",
      "            Current function value: 0.6682634107156029\n",
      "            Iterations: 1\n",
      "            Function evaluations: 19\n",
      "            Gradient evaluations: 1\n"
     ]
    }
   ],
   "source": [
    "solution = minimize(obj, x0, method='SLSQP', bounds=bnds, tol=0.01, options={\"maxiter\":1000, 'disp': True})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.6682634107156029\n"
     ]
    },
    {
     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0vCnnOrbVAADtsXQCAPRG0AAAeiNoAAC9ETQAgN4IGgBAbwQNAKA3ggYA0Jv/D/JxmUvXYsuNAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 720x720 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "print(obj(solution.x))\n",
    "draw_accuracies(beacon_locations_from_x(solution.x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "from utils import cartesian_cross_product\n",
    "res = np.apply_along_axis(obj, 1, cartesian_cross_product(np.arange(0, 3, 0.1), np.arange(0, 4, 0.1)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
